"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
console.log('This is my first typescript application.');
var User = /** @class */ (function () {
    function User(id, name) {
        this.name = name;
        this.id = id;
    }
    User.prototype.showName = function () {
        console.log(this.name);
    };
    return User;
}());
var Role = /** @class */ (function () {
    function Role() {
    }
    return Role;
}());
function getById(id) {
    var user = new User(id, "gainorloss");
    return user;
}
var role = new Role();
role.id = 1;
role.name = '管理员';
console.log(role.id);
var registered = true;
var str = "gainorloss";
var num = 1;
var strArr = ["gain", "loss", "or"];
var strArr_ = ["gain", "or", "loss"];
var tuple = ["gain", 3, "string", 4, 6, 7];
var Color;
(function (Color) {
    Color[Color["Red"] = 6] = "Red";
    Color[Color["Yellow"] = 7] = "Yellow";
    Color[Color["Green"] = 8] = "Green";
    Color[Color["Blue"] = 9] = "Blue";
})(Color || (Color = {}));
console.log(Color.Yellow);
var obj = 'string';
obj = false;
obj = 123;
console.log(obj);
var un;
console.log(un);
function createUser() {
    console.log("create user.");
}
var oBtn = document.getElementById('btn');
console.log(oBtn.innerText = "Please click me");
function getName(name, age) {
    if (age === void 0) { age = 25; }
    if (name) {
        console.log(name + "___" + age);
        return;
    }
    console.log("" + age);
}
getName("gainorloss", 26);
function add(left) {
    var para = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        para[_i - 1] = arguments[_i];
    }
    var sum = left;
    for (var i in para) {
        sum += para[i];
    }
    return sum;
}
var rt = add(1, 2, 3, 4, 5);
console.log(rt);
function getString(any) {
    if (typeof any === 'string') {
        return "string___" + any;
    }
    else {
        return typeof any + "___" + num.toString();
    }
}
console.log(getString(true));
var Person = /** @class */ (function () {
    function Person(name, age) {
        this.name = name;
        this.age = age;
    }
    Person.prototype.sayHello = function () {
        console.log(this.name + ":hello!");
    };
    return Person;
}());
var Chinese = /** @class */ (function (_super) {
    __extends(Chinese, _super);
    function Chinese(name, age) {
        return _super.call(this, name, age) || this;
    }
    return Chinese;
}(Person));
var chinese = new Chinese("gainorloss", 26);
chinese.sayHello();
var Animal = /** @class */ (function () {
    function Animal(name, age) {
        this.name = name;
        this.age = age;
    }
    Animal.prototype.eat = function () {
        console.log(this.name + " is eating!");
    };
    Animal.run = function () {
        console.log("Animal is eating!");
    };
    Animal.nickName = 'wildLife';
    return Animal;
}());
console.log(Animal.nickName);
Animal.run();
var Life = /** @class */ (function () {
    function Life(type) {
        this.type = type;
    }
    return Life;
}());
var WildLife = /** @class */ (function (_super) {
    __extends(WildLife, _super);
    function WildLife(type) {
        return _super.call(this, type) || this;
    }
    WildLife.prototype.run = function () {
        console.log('WildLife run');
    };
    return WildLife;
}(Life));
var life = new WildLife("豹子");
life.run();
function getFullName(fullName) {
    console.log("" + fullName.firstName + fullName.lastName);
}
var fullName = { firstName: '张', lastName: '三' };
getFullName(fullName);
function ajax(config) {
    var xhr = new XMLHttpRequest();
    xhr.open(config.type, config.url, true);
    xhr.send(config.data);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            if (config.dataType == 'json') {
                console.log(JSON.parse(xhr.responseText));
            }
            else {
                console.log(xhr.responseText);
            }
        }
    };
}
var doSomething = function (firstName, lastName) {
    return firstName + " " + lastName;
};
console.log(doSomething('张', '建'));
var People = /** @class */ (function () {
    function People() {
    }
    People.prototype.SayHello = function (message) {
        console.log(message);
    };
    return People;
}());
var Human = /** @class */ (function () {
    function Human(name) {
        this.name = name;
    }
    Human.prototype.eat = function () {
        console.log(this.name + " is eating!");
    };
    return Human;
}());
var Americal = /** @class */ (function (_super) {
    __extends(Americal, _super);
    function Americal(name) {
        return _super.call(this, name) || this;
    }
    Americal.prototype.work = function () {
        console.log(this.name + " is working.");
    };
    return Americal;
}(Human));
function get(val) {
    return val;
}
var str = get("gainorloss");
var num = get(123);
var boo = get(true);
var MyClassName = /** @class */ (function () {
    function MyClassName() {
    }
    MyClassName.prototype.get = function (val) {
        return val;
    };
    return MyClassName;
}());
var myClassName = new MyClassName();
var string = myClassName.get("gainorloss");
